package com.cxq;

import java.util.concurrent.locks.ReentrantLock;

/**
 * Created by cxq on 2020/7/26.
 */

//可重入锁
public class ReentrantLockDemo {
    public static void main(String[] args) {
        ReentrantLock lock = new ReentrantLock();
        for (int i = 0; i < 10; i++) {
            lock.lock();
            System.out.println("加锁次数"+i);
        }
        for (int i=0;i<10;i++){
            lock.unlock();
            System.out.println("解锁次数"+i);
        }
    }
}
